package com.hospital.demo.controller.gaoyuran;

import com.hospital.demo.model.gaoyuran.Equipment;
import com.hospital.demo.service.gaoyuran.EquipmentSer;
import com.hospital.demo.util.ResultUtils;
import com.hospital.demo.util.ResultVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.List;

@RestController
@RequestMapping("/equipment")
@Api(tags={"G_器材接口"})
public class EquipmentCon {

    @Autowired
    private EquipmentSer equipmentSer;


    @GetMapping("/get")
    public ResultVO viewequ(Integer meid) {
        Equipment equipment = equipmentSer.get(meid);
        return ResultUtils.success(Arrays.asList(equipment));
    }

    @ApiOperation(value = "获取全部未使用器材信息", notes = "")
    @RequestMapping(value = "/findallequipmentno")
    private ResultVO findallequipmentno() {
        return ResultUtils.success(equipmentSer.findallequipmentno());
    }

    @ApiOperation(value = "获取全部器材信息", notes = "")
    @RequestMapping(value = "/findallequipment")
    private ResultVO findallequipment() {
        return ResultUtils.success(equipmentSer.findallequipment());
    }


    @ApiOperation(value = "添加器材信息", notes = "")
    @PostMapping("/addEquipment")
    private ResultVO addEquipment(Equipment equipment) {
        return ResultUtils.success(equipmentSer.addEquipment(equipment));
    }

    @ApiOperation(value = "更新器材信息", notes = "")
    @PostMapping("/upDateEquipment")
    private ResultVO upDateEquipment(Equipment equipment) {
        return ResultUtils.success(equipmentSer.upDateEquipment(equipment));
    }

    @ApiOperation(value = "通过id删除器材信息", notes = "")
    @PostMapping("/delEquipmentById")
    private ResultVO delEquipmentById(@RequestParam(name = "meid", defaultValue = "-1") Integer meid ){
        return ResultUtils.success(equipmentSer.delEquipmentById(meid));
    }
}
